package com.own.business.system.user.wechat.core.entity.form;

import com.own.component.common.exception.BusinessException;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;

/**
 * WechatLoginForm
 *
 * @author chenxueli
 * @date 2023-06-30 11:44:00
 */
@Data
public class WechatLoginForm implements Serializable {

    @Schema(title = "微信openId")
    private String openId;

    @Schema(title = "账号类型 1=普通用户 2=管理员")
    private Integer accountType;

    private void init() {
        if (accountType == null) {
            accountType = 1;
        }
    }

    /**
     * 验证信息
     */
    public void check() {
        this.init();
        if (StringUtils.isBlank(this.openId)) {
            throw new BusinessException("openId不能为空");
        }
    }

}
